﻿import QtQuick 2.0
import ImageItem 1.0

Item{
    property string carName: "平地机\n   001"
    property real bandwidth: 126
    property string pingTime

    Image{
        id: carNameImg
        z: 1
        source: "qrc:/grader/imgs/car_name_bg.png"
        Text {
            id: carNameText
            text: carName
            anchors.centerIn: parent
            color: "#00FFFF"
            font{
                family: "Microsoft YaHei"
                pixelSize: 37
            }
        }
    }

    Image{
        id: modeImg
        z: 1
        y: -25
        anchors.left: carNameImg.right
        anchors.leftMargin: -75
        source: "qrc:/grader/imgs/mode_wifi_bg.png"
        Row{
            spacing: 40
            anchors.centerIn: parent
            Text {
                id: controlModeText
                anchors.verticalCenter: parent.verticalCenter
                text: can_manager.remote_state ? "远程模式" : "观看模式"
                color: can_manager.remote_state ? "#00FF00" : "white"
                font{
                    family: "Microsoft YaHei"
                    pixelSize: 40
                }
            }

            Row{
                spacing: 10

                Image {
                    anchors.verticalCenter: parent.verticalCenter
                    source: "qrc:/grader/imgs/wifi.png"
                }
                Text{
                    anchors.verticalCenter: parent.verticalCenter
                    text: String(pingTime) + " ms"
                    color: can_manager.remote_state ? "#00FF00" : "white"
                    font{
                        family: "Microsoft YaHei"
                        pixelSize: 40
                    }
                }
            }
        }
    }


    Rectangle {
        id: graderBoardRect
        z: 0
        anchors.top: modeImg.bottom
        anchors.topMargin: -30
        anchors.left: carNameImg.right
        anchors.leftMargin: -60
        width: 570
        height: 600
        color: Qt.rgba(0,1,1,0.25)
        border.color: "#00FFFF"
        border.width: 4
        radius: 10

        Column{
            anchors.centerIn: parent
            spacing: 10
            Row{
                id: boardRow
                spacing: 30
                anchors.horizontalCenter: parent.horizontalCenter
                DashBoardBeta{
                    id: mySpeedItem
                    current_speed:(can_manager.speed_single / 23).toFixed(1)
                }

                DashBoardBeta{
                    id: myoilItem
                    display_mode: true
                    current_engine: can_manager.engine_speed.toFixed(0)
                    gear_position: can_manager.indicator_gears_forward
                    gear_direction: can_manager.gear_direction_forward
                }
            }

            Column{
                id: scaleDataCol
                spacing: 10
                anchors.horizontalCenter: parent.horizontalCenter
                ScaleData{
                    maxValue: 120
                    scaleCount: 3
                    unitName: "℃"
                    scaleWarnLength: 56
                    iconSource: "qrc:/grader/imgs/engine_tel_main.png"
                    currentValue: can_manager.engine_water_temperature.toFixed(0)
                }

                ScaleData{
                    maxValue: 10
                    scaleCount: 3
                    unitName: "bar"
                    scaleWarnLength: 109
                    iconSource: "qrc:/grader/imgs/engine_yali_main.png"
                    currentValue: can_manager.engine_lubricating_oil_pressure.toFixed(0)
                }

                ScaleData{
                    maxValue: 150
                    scaleCount: 4
                    unitName: "℃"
                    scaleWarnLength: 87
                    iconSource: "qrc:/grader/imgs/oil_tep_main.png"
                    currentValue: can_manager.torque_converter_oil_temperature.toFixed(0)
                }

                ScaleData{
                    maxValue: 25
                    scaleCount: 6
                    unitName: "bar"
                    scaleWarnLength: 77
                    scaleWarnLength2: 104
                    iconSource: "qrc:/grader/imgs/yali_main.png"
                    currentValue: can_manager.torque_converter_oil_pressure.toFixed(0)
                }
            }
        }

    }

    function updateVisible(v1, v2){
        boardRow.visible = v1;
        scaleDataCol.visible = v2;
        graderBoardRect.height = 40;
        if(v1) graderBoardRect.height+=boardRow.height+20;
        if(v2) graderBoardRect.height+=scaleDataCol.height+20;
        if(!v1&&!v2) graderBoardRect.visible = false;
        else graderBoardRect.visible = true
    }


}

